
import {SecurityUser} from "@/type/SecurityUser";
import ProForm, {
    InputDateTime,
    InputNumber,
    InputRadio,
    InputSelect,
    InputSwitch,
    InputText,
    InputTextArea
} from "@/common/form";
import dayjs from "dayjs";
import {DATETIME_FORMAT} from "@/global/constant.ts";

const UserAddComponent = () => {
    return (
        <>
            <ProForm<SecurityUser>
                title={"添加用户信息"}
                backText={"用户列表"}
                initialValues={{
                    username: "ad",
                    enabled: true,
                    order: 1,
                    identity: "2",
                    accountNonLocked: false,
                    createTime: dayjs("2023-10-12 10:25:36"),
                }}
                formDataConvert={formData => {
                    if (dayjs.isDayjs(formData.createTime)){
                        formData.createTime =formData.createTime.format(DATETIME_FORMAT);
                    }
                    return formData;
                }}
            >
                <InputText<SecurityUser> name={"username"} label={"用户名"} required/>
                <InputDateTime<SecurityUser> name={"createTime"} label={"创建时间"}/>
                <InputRadio<SecurityUser>
                    name={"accountNonLocked"}
                    label={"用户锁定状态"}
                    firstText={"未锁定"}
                    lastText={"已锁定"}
                />
                <InputSwitch<SecurityUser> name={"enabled"} label={"用户状态"} required/>
                <InputNumber
                    max={25}
                    required
                    name={"order"} label={"用户排序"} min={0}/>
                <InputTextArea<SecurityUser>
                    name={"remark"}
                    label={"备注信息"}
                    rows={3}
                />

                <InputSelect<SecurityUser> options={""} name={"identity"} label={"用户身份"}/>
            </ProForm>
        </>
    );
};

export default UserAddComponent;